package com.dongdongshop.controller;
import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.data.Result;
import com.dongdongshop.em.ConstantEnum;
import com.dongdongshop.pojo.TbOrder;
import com.dongdongshop.pojo.TbUser;
import com.dongdongshop.service.TbOrderService;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
@Controller
@RequestMapping("order")
public class OrderController {
    @Reference
    private TbOrderService  tbOrderService ;
    //点击提交订单的时候往数据库的订单表中添加数据
    @RequestMapping("addOrderInfo")
    @ResponseBody
    public Result addOrderInfo (TbOrder order){
        TbUser user = (TbUser) SecurityUtils.getSubject().getPrincipal();
        order.setUserId(user.getUsername());
         Map<Object,Object> map =tbOrderService.addInfo(order);
        return Result.build(ConstantEnum.SUCCESS).setResult(map);
    }
    @RequestMapping("toPay")
    public String toPay(){
        return "pay";
    }
}
